package com.example.feign;

import com.alibaba.fastjson.JSONObject;
import com.example.auth.domain.DataNode;
import com.example.util.MethodDesc;
import com.example.util.Module;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

@Module(name = "节点服务模块", description = "查询数据节点")
@FeignClient(value = "cloud-auth",fallback = com.example.feign.impl.NodeFeignServiceImpl.class)
public interface NodeFeignService {

    @MethodDesc(description = "根据id查找节点")
    @GetMapping("/node/getone")
    DataNode getDataNodeConfigById(@RequestParam("id")String id);

    @MethodDesc(description = "根据服务名查找完整节点")
    @GetMapping("/node/getone/servername")
    DataNode getDataNodeConfigByServerName(@RequestParam("serverName")String serverName);

    @MethodDesc(description = "获取所有节点")
    @GetMapping("/node/getallnode")
    List<DataNode> getDataNodeConfigList();

    @MethodDesc(description = "新增节点/更新节点")
    @PostMapping("/node/saveorupdate")
    JSONObject saveOrUpdateDataNode(@RequestBody JSONObject jsonObject);
}
